//
//  MKMyViewMerchantThreeTabCell.swift
//  MOKOAnnounce
//
//  Created by 曹相召 on 2017/7/10.
//  Copyright © 2017年 cc.moko. All rights reserved.
//

import UIKit

class MKMyViewMerchantThreeTabCell: MKBaseTableViewCell {

    var collect:MKMyViewTabCellButton!
    var money:MKMyViewTabCellButton!
    var service:MKMyViewTabCellButton!

    var meAgentInfoModel:MKMeAgentInfoModel?{
        didSet{
            if let keepNumber = meAgentInfoModel?.agentKeepCount{
              self.collect.config(tip: "我的收藏", num: keepNumber)
            }
            if let accountNumber = meAgentInfoModel?.agentAccountCount{
                self.money.config(tip: "会员余额", num: accountNumber)
            }
            if let buyNumber = meAgentInfoModel?.agentBuyCount{
                self.service.config(tip: "购买历史", num: buyNumber)
            }
        }
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.makeUI()
    }
    
    func makeUI() -> Void {
        
        self.collect = MKMyViewTabCellButton()
        self.collect.tag = 100;
        self.collect .addTarget(self, action: #selector(tabClick(btn:)), for: .touchUpInside)
        self.contentView.addSubview(self.collect)
        
        self.money = MKMyViewTabCellButton()
        self.money.tag = 101;
        self.money .addTarget(self, action: #selector(tabClick(btn:)), for: .touchUpInside)
         self.contentView.addSubview(self.money)
        
        self.service = MKMyViewTabCellButton()
        self.service.tag = 102;
        self.service .addTarget(self, action: #selector(tabClick(btn:)), for: .touchUpInside)
        self.contentView.addSubview(self.service)
        
        self.collect.config(tip: "我的收藏", num: 0)
        self.money.config(tip: "会员余额", num: 0)
        self.service.config(tip: "购买历史", num: 0)

    }
    func tabClick(btn:MKMyViewTabCellButton) -> Void{
//        if()
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        let buttonWidth = (self.width - 14) / 3.0
        
        self.collect.frame = CGRect.init(x: 7, y: 0, width: buttonWidth, height: self.contentView.height)
        self.money.frame = CGRect.init(x: buttonWidth + 7, y: 0, width: buttonWidth, height: self.contentView.height)
        self.service.frame = CGRect.init(x: buttonWidth * 2 + 7, y: 0, width: buttonWidth, height: self.contentView.height)
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
